<template>
    <article>
        <header>滚动加载</header>
        <section v-scroll-load="load" 
                :scroll-load-disabled = "disabled"
                scroll-load-delay="200"
                scroll-load-distance="0"
                scroll-load-immediate>
            <div v-for="index in size" :key="index">{{index}}</div>
        </section>
    </article>
</template>

<script>
    export default {
        name: "ExampleScrollLoad",
        data() {
            return {
                disabled: false,
                size: 0
            };
        },
        methods: {
            async load() {
                // console.info("load");
                
                return new Promise(resolve => {
                    setTimeout(() => {
                        this.size += 3;
                        
                        // console.info("load executed");
                        
                        resolve();
                    }, 1000);
                });
            }
        }
    }
</script>

<style scoped lang="scss">
    section {
        max-width: 1000px;
        overflow: scroll;
        height: 500px;;
        
        div {
            height: 50px;
            margin-top: 10px;
            line-height: 50px;
            text-align: center;
            background-color: var(--color-primary-1);
            border: 1px solid var(--color-primary);
        }
    }
</style>
